import { IsDate, IsEnum, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString } from 'class-validator'
import { Type } from 'class-transformer'
import { CUserStatus, CGuardianRelation } from '../constant'

export class CreateUserDto {
  @IsString()
  @IsOptional()
  userId: string

  @IsString()
  @IsNotEmpty()
  @IsPhoneNumber('CN')
  phone: string

  @IsString()
  @IsNotEmpty()
  userName: string

  @IsString()
  @IsNotEmpty()
  guarder: string

  @IsString()
  @IsNotEmpty()
  @IsPhoneNumber('CN')
  guarderPhone: string

  @IsEnum(CGuardianRelation)
  @IsOptional()
  guarderRelation: CGuardianRelation

  @IsOptional()
  @Type(() => Date)
  @IsDate()
  birthday?: Date

  @IsString()
  @IsOptional()
  school: string

  @IsString()
  @IsNotEmpty()
  province: string

  @IsString()
  @IsNotEmpty()
  city: string

  @IsInt()
  @IsNotEmpty()
  grade: number

  @IsInt()
  @IsOptional()
  from: number

  @IsEnum(CUserStatus)
  @IsNotEmpty()
  status: CUserStatus

  @IsString()
  @IsOptional()
  mark: string

  @IsInt()
  @IsOptional()
  createBy?: number

  @IsInt()
  @IsOptional()
  updateBy?: number
}
